package com.demo.hxs.service;

import com.alibaba.excel.EasyExcel;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.demo.hxs.entity.OrderTable;
import com.demo.hxs.mapper.OrderTableMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class OrderTableService extends ServiceImpl<OrderTableMapper, OrderTable> {
    @Resource
    private OrderTableMapper orderTableMapper;

    public List<OrderTable> selectAll(){
        return orderTableMapper.selectList(null);
    }

    public IPage<OrderTable> selectPage(Page<OrderTable> page) {
        return page(page, new QueryWrapper<>()); // 使用 page 方法进行分页查询，传入 Page 对象和查询条件（这里使用空的条件）
    }

    public void simpleWrite(){
        long start = System.currentTimeMillis();
        String fileName="C:\\Users\\123\\Desktop\\orders.xlsx";
        EasyExcel.write(fileName, OrderTable.class).sheet("Sheet2").doWrite(selectAll());
        long end = System.currentTimeMillis();
        System.out.println("整个接口耗时："+(end-start)+"ms");

    }
}
